﻿@model LastoRevival.Service.Contracts.Models.Thread
@using LastoRevival.Service.Contracts.Models;

<div class="thread collapsible" id="thread-@Model.Details.ThreadID">

	<div class="collapsers">

	@{ var collapsed = (Model.Details.MessagesInThread >= Html.UserSettings().CollapseThreshold) && Html.UserSettings().CollapseThreads; }

	@Html.Transparent("thread-collapse-" + Model.Details.ThreadID, "thread-collapse", !collapsed, "collapseThread('" + Model.Details.ThreadID + "')")
	@Html.Transparent("thread-expand-" + Model.Details.ThreadID, "thread-expand", collapsed, "expandThread('" + Model.Details.ThreadID + "')")
	</div>
	<div class="post">
	
		@{
			var displayState = collapsed ? "display: none;" : "";
			ViewBag.Level = 1;
		}

		@Html.Partial("MessagePreview", Model.TopMessage)

		@{ ViewBag.Level++; }
	
		<span id="thread-children-@Model.Details.ThreadID" class="collapsible-post" style="@displayState">
			@foreach (var child in Model.TopMessage.ChildPosts)
			{	   
				@Html.Partial("Thread", child);
			}
		</span>

	</div>
</div>